home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / CMD-. < prev    next >
Text File  |  1990-05-05  |  2KB  |  42 lines

  1. /*    This is a simple extension to CSwitchboard to detect cmd-period
  2. )5/4/1990  version 1.0
  3. by j "Knife-the-Mac" geagan, AKA Pad-Parrot Productions  CIS:71311,301
  4. no rights reserved; free; etc., etc.
  5. Hey Symantec: Please (feel free to) include this in THINK C 5.0
  6.  % It patches the Switchboard to send a "cmdPeriod" message to gGopher
  7.      if there is no active menu item for command-period
  8.  % To use, just add this file to your project and remove <CApplication.C>
  9.  % No need to worry about "#include <CApplication.h>" - no changes there
  10.  % You also need to create a <Ccommands.h> file that #defines cmdPeriod
  11.      as your desired command-number
  12. */
  13.  
  14. #include <Ccommands.h>    /* YOU must create this file! */
  15. #include <CSwitchboard.h>
  16. #include <CBureaucrat.h>
  17. #include <CBartender.h>
  18. #include <Global.h>
  19.  
  20. extern CBureaucrat    *gGopher;
  21. extern CBartender    *gBartender;
  22.  
  23. struct    jSwitchboard:CSwitchboard    {
  24.     void    DoKeyEvent(EventRecord*);
  25. };
  26. void    jSwitchboard::DoKeyEvent(register EventRecord    *macEvent)    {
  27. register char    theChar=macEvent->message & charCodeMask;
  28.     if (theChar=='.' && (macEvent->what==keyDown && (macEvent->modifiers & cmdKey)))    {
  29.         gBartender->UpdateAllMenus();    /* it's a command-period; look in menus */
  30.         if (!HiShort(MenuKey(theChar)))    {    /* no menu command for CMD-PERIOD */
  31.             gGopher->DoCommand(cmdPeriod);
  32.             return;
  33.             }
  34.         /* else it will hilite the menu again (in inherited), but so what? */
  35.         }
  36.     inherited::DoKeyEvent(macEvent);
  37. }
  38.  
  39. /* override any CSwitchboard uses in CApplication to jSwitchboard */
  40. #define    CSwitchboard    jSwitchboard
  41.  
  42. #include <CApplication.